<template>
  <el-dialog
    title="结果提示"
    :visible.sync="dialogVisible"
    :before-close="cancel"
    width="500px"
    @open="getList"
    :close-on-click-modal="true"
    append-to-body
  >
    <div style="margin-bottom: 10px;">请选择下载的总分Excel表模板</div>
    <el-table
      :data="tableData"
      :loading="loading"
      highlight-current-row
      style="width: 100%"
      @current-change="handleSelectionChange">
      <el-table-column width="55" align="center">
        <template slot-scope="scope">
          <!-- <el-checkbox v-model="scope.row.checked"></el-checkbox> -->
          <el-radio v-model="checked" :label="scope.row.id"></el-radio>
        </template>
      </el-table-column>
      <el-table-column label="总分模板" align="center" prop="name" />
      <el-table-column label="包含字段" align="center" prop="content" nin- width="245"/>
    </el-table>
    <span slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
      <el-button type="primary" @click="submit">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import {exportScoreExcel, queryExportScoreExcelProcess} from "@/api/toolsystem/grade";
  export default {
    name: "downloadToServe",
    props:{
      dialogVisibleFu:Boolean,
      errorData:Array
    },
    data() {
      return {
        loading: false,
        tableData: [],
        checked: '', // 选中的id-如果使用单选框,定义一个model值
        dialogVisible:this.dialogVisibleFu,
      };
    },
    methods: {
      getList () {
        this.loading = true;
        let resData = [{
          id: 1,
          name: '校考版',
          content: '姓名、准考证号、身份证号、单科总分'
        }, {
          id: 2,
          name: '标考版',
          content: '省份、学校、姓名、总分、全国百分比、全省百分比、单科总分、单科全国百分比、单科全省百分比'
        }]
        this.tableData = resData
        this.loading = false;
      },
      //单选-获取选中数据
      handleSelectionChange (row) {
        if(row){
          this.checked = row.id
        }

      },
      // 确认按钮操作
      submit(){
        if(!this.checked){
          return this.msgInfo('请选择模板')
        }
        this.dialogVisible = false
        this.$emit('closeDialog', false, this.checked)
        this.checked = ''
      },
      // 关闭操作
      cancel(){
        this.dialogVisible = false
        this.$emit('closeDialog', false)
        this.checked = ''
      },
    },
    watch:{
      dialogVisibleFu(val){
        this.dialogVisible = val
      }
    }
  };
</script>

<style scoped lang="scss">
  ::v-deep .el-radio__label {
    font-size: 0;
    padding-left: 0;
  }
</style>

